import axios from 'axios'

export default function fetch(options) {
  return new Promise((resolve, reject) => {
    //创建一个axios实例
    const instance = axios.create({
      //设置默认根地址
      baseURL: 'http://119.23.218.131:9302',
      //设置请求超时设置
      timeout: 20000,
      //设置请求时的header
      headers: {
        contentType:"application/json",
      },
      method: options.method || 'GET',
      //async: options.async || true
    })
    instance(options)
      .then((data) => {
        resolve(data);
      })
      .catch((error) => {
        reject(error)
      })
  })
}
